var _n15;
var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_BundleManager = _n15 = /* */function (_cc$Component9) {
  babel_inherits(n, _cc$Component9);
  var _super10 = babel_createSuper(n);
  function n() {
    babel_classCallCheck(this, n);
    return _super10.apply(this, arguments);
  }
  babel_createClass(n, [{
    key: "loadBundle",
    value: function loadBundle(e) {
      return new Promise(function (t, a) {
        cc.assetManager.loadBundle(e, function (_n16, i) {
          if (_n16) {
            console.warn("资源包加载失败", _n16);
            a("资源包" + e + "加载失败");
          } else {
            console.log("资源包" + e + "加载成功");
            t(i);
          }
        });
      });
    }
  }, {
    key: "preLoadBundleDir",
    value: function preLoadBundleDir(e, t, a, _n17, i) {
      var _this27 = this;
      return new Promise(function (s, o) {
        _this27.getBundle(e).loadDir(t, a, function (e, t) {
          _n17 && _n17(e, t);
        }, function (e, t) {
          if (e) {
            console.error("资源包加载失败", e);
            o();
          }
          i && i(e, t);
          s();
        });
      });
    }
  }, {
    key: "preload",
    value: function preload(e, t, a, _n18, i) {
      this.getBundle(e).loadDir(t, a, function (e, t) {
        _n18 && _n18(e, t);
      }, function (e, t) {
        e && console.warn("资源包加载失败", e);
        i && i(e, t);
      });
    }
  }, {
    key: "loadBundleRes",
    value: function loadBundleRes(e, t, a, _n19) {
      var _this28 = this;
      var i = this.getBundle(e);
      if (i) {
        i.load(t, a, function (e, t) {
          _n19 && _n19(e, t);
        });
      } else {
        this.loadBundle(e).then(function () {
          (i = _this28.getBundle(e)).load(t, a, function (e, t) {
            _n19 && _n19(e, t);
          });
        });
      }
    }
  }, {
    key: "getBundleRes",
    value: function getBundleRes(e, t, a) {
      var _this29 = this;
      var _n20;
      var i = this.getBundle(e);
      if (i) {
        if (_n20 = i.get(t, a)) {
          return _n20;
        }
        this.loadBundleRes(e, t, a, function () {
          return _this29.getBundleRes(e, t, a);
        });
      } else {
        this.loadBundle(e);
      }
    }
  }, {
    key: "getBundle",
    value: function getBundle(e) {
      var t = cc.assetManager.getBundle(e);
      t || this.loadBundle(e).then(function (e) {
        return e;
      }).catch(function (e) {
        console.log(e);
      });
      return t;
    }
  }], [{
    key: "instance",
    get() {
      this._instance || (this._instance = new _n15());
      return this._instance;
    }
  }]);
  return n;
}(cc.Component);
def_BundleManager = _n15 = cc__decorate([ccp_ccclass], def_BundleManager);
exports.default = def_BundleManager;